package com.campus.customer.mapper;

import com.campus.customer.entity.Notice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 公告表 Mapper 接口
 * </p>
 *
 * @author ZhaoYuJie
 * @since 2025-07-15
 */
public interface NoticeMapper extends BaseMapper<Notice> {

    /**
     * 增加公告查看次数（高并发安全）
     * @param id 公告ID
     * @return 更新行数
     */
    @Update("UPDATE notice SET view_count = view_count + 1 WHERE id = #{id} AND del_flag = 0")
    int incrementViewCount(@Param("id") Integer id);
}
